package com.neusoft.${bigModuleName}.service.provider.${tableName};

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neusoft.${bigModuleName!}.remote.dto.${tableName}.${TableName}Dto;
import com.neusoft.${bigModuleName!}.remote.service.${tableName}.I${TableName}Service;
import com.neusoft.${bigModuleName!}.dao.entity.${tableName}.${TableName};
import com.neusoft.${bigModuleName!}.dao.mapper.${tableName}.${TableName}Mapper;
import com.panshicloud.common.base.PageDto;
import com.panshicloud.common.helper.ConvertHelper;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

/**
* ${tableComment!}
* @author ${author}
* @since ${date}
*/
@DubboService
public class ${TableName}Service extends ServiceImpl<${TableName}Mapper, ${TableName}> implements I${TableName}Service {
    @Override
    public boolean doUpsert(${TableName}Dto dto) {
        ${TableName} entity = ConvertHelper.tToV(dto, ${TableName}.class);
        return this.saveOrUpdate(entity);
    }

    @Override
    public ${TableName}Dto doGetById(String id) {
        return ConvertHelper.tToV(this.getById(id), ${TableName}Dto.class);
    }

    @Override
    public boolean doRemove(List<String> ids) {
        return this.removeByIds(ids);
    }

    @Override
    public PageDto<${TableName}Dto> doPage(long pageNumber, long pageSize, ${TableName}Dto dto) {
        QueryWrapper<${TableName}> wrapper = new QueryWrapper<>();


        Page<${TableName}> dataPage = this.page(new Page<>(pageNumber, pageSize), wrapper);
        PageDto<${TableName}Dto> pageDto = new PageDto<>(dataPage,${TableName}Dto.class);
        return pageDto;
    }

    @Override
    public List<${TableName}Dto> doList() {
        List<${TableName}> list = this.list();
        return ConvertHelper.tToV(list, ${TableName}Dto.class);
    }
}

